﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CNVP.JShop.UI;
using CNVP.Framework.Utils;

using CNVP.Config;

namespace CNVP.JShop.Web.Admin
{
    public partial class Header : AdminPage
    {
        private string Prefix = DBConfig.Prefix;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                lbUserName.Text = CookieString;
                TopMenu();
            }
        }
        private void TopMenu()
        {
            BLL.BLLMenu bll = new BLL.BLLMenu();
            string html = "";
            var list_topMenu = bll.GetAll_CNVP_Menu("Depth=0 order by Weight");
            for (int i = 0; i < list_topMenu.Count; i++)
            {
                string userName = CookieString;
                int AdminRoleID = CookieRoleID;
                var menuList = bll.GetAll_CNVP_Menu("Depth=" + list_topMenu[i].ID + " AND ID in (select MenuID from " + Prefix + "AdminRoleMenu where AdminRoleID=" + AdminRoleID + ") order by Weight");
                if (menuList.Count > 0)
                {
                    html += "<a  href=\"LeftNav.aspx?ID=" + list_topMenu[i].ID + "\" target=\"LeftNav\" id=\"Index" + list_topMenu[i].ID + "\" name=\"IndexName\">" + list_topMenu[i].MenuName + "</a>  |  ";
                }
            }
            lbTopMenu.Text = html;
        }
    }
}